<?php
/**
 * The following variables are available in this template:
 * - $this: the CrudCode object
 */
?>
<?php
echo "<?php\n";
$nameColumn=$this->guessNameColumn($this->tableSchema->columns);
$label=$this->pluralize($this->class2name($this->modelClass));
echo "\$this->pageTitle = 'View $label';\n";
echo "\$this->breadcrumbs=array(
	'$label'=>array('index'),
	\$model->{$nameColumn},
);\n";
?>
?>
<div class="heading">
    <h1><img src="<?php echo '<?php echo Util::themeUrl() ?>'; ?>/images/default.png" />View <?php echo $this->modelClass." #<?php echo \$model->{$this->tableSchema->primaryKey}; ?>"; ?></h1>
    <div class="controls"> 
        <?php echo "<?php\n" ; ?>
        if (isset($_GET['ajax'])) {
            echo CHtml::button('Create', array('class' => 'controls', 'onclick' => "location.href='" . <?php echo "\$this->createUrl('create', array('ajax' => true))";?> . "'"));
            echo CHtml::button('Update', array('class' => 'controls', 'onclick' => "location.href='" . <?php echo "\$this->createUrl('update', array('id' => \$model->".$this->tableSchema->primaryKey.", 'ajax' => true))";?> . "'"));
            echo CHtml::ajaxButton('Delete', array('delete', 'ajax' => true), array(
                'type' => 'post',
                'data' => "chk[]={$model->id}",
                'success' => 'function(data){$(".controls").hide(); $(".content").html(data);}'
            ), array('class' => 'controls'));
        } else {
            echo CHtml::link('Manage', array('index'), array('class' => 'controls'));
            echo CHtml::link('Create', array('create'), array('class' => 'controls'));
            echo CHtml::link('Update', array('update', 'id' => $model-><?php echo $this->tableSchema->primaryKey;?>), array('class' => 'controls'));
            echo CHtml::link('Delete', array('delete'), array(
                'class' => 'controls', 
                'submit' => array('delete'), 
                'confirm'=>'Are you sure you want to delete this item?',
                'params' => array('chk[]' => $model-><?php echo $this->tableSchema->primaryKey;?>),
                'ajax' => array('type' => 'post')
            ));
        }
     <?php echo "?>\n";?>
    </div>
</div>

<div class="content">
<?php echo "<?php"; ?> $this->widget('zii.widgets.CDetailView', array(
	'data'=>$model,
	'attributes'=>array(
<?php
foreach($this->tableSchema->columns as $column)
	echo "\t\t'".$column->name."',\n";
?>
	),
)); ?>
</div>
